<?php
namespace app\common\model;
/**
* Featured
*/
class Featured extends BaseModel
{
    //重写了BaseModel的add方法，因为推荐添加默认状态为1
	public function add($data){
		$data['status'] = 1;
		$this->save($data);

		return $this->id;
	}

	//根据类型来获取推荐位列表信息
	public function getFeaturedsByType($type){
		$data = [
			'type' => $type,
			'status' => ['neq',-1],
		];

		$order = ['id'=>'desc'];
		$result = $this->where($data)
		    ->order($order)
		    ->paginate();
		return $result;
	}
}